#ifndef __GATEWAY_HANDLER_H__
#define __GATEWAY_HANDLER_H__
#include <ace/Reactor.h>
#include <ace/streams.h>
#include <ace/INET_Addr.h>
#include <ace/Svc_Handler.h>
#include <ace/SOCK_Acceptor.h>
#include <ace/Acceptor.h>

#include <RpcChannel.h>

class GateWayHandler 
	: public RpcChannel
{
	enum{ BUFFER_SIZE=2048 };
public: 
	static GateWayHandler *instance();
public:
	~GateWayHandler();
public:
	//int open(void * /* = 0 */);
	int handle_input(ACE_HANDLE);
	//int handle_output(ACE_HANDLE fd /* = ACE_INVALID_HANDLE */);
	int handle_close(ACE_HANDLE,ACE_Reactor_Mask);

public:
private:
	GateWayHandler();
private:
};

class GateWayAcceptor : public ACE_Event_Handler
{
public:
	GateWayAcceptor(void);
	~GateWayAcceptor(void);
public:
	ACE_HANDLE get_handle() const;
	int open(ACE_INET_Addr const &addr);
	int handle_input(ACE_HANDLE fd /* = ACE_INVALID_HANDLE */);
	int handle_close(ACE_HANDLE handle, ACE_Reactor_Mask close_mask);

private: 
	ACE_SOCK_Acceptor	_acceptor;
	
};



#endif